/**
 * UploadAction.java
 * jp.co.greenblue.ecodasweb.web.struts2.action
 *
 * Function： TODO 
 *
 *   ver     date      		author
 * ──────────────────────────────────
 *   		 2010/11/12 		jonsion
 *
 * Copyright (c) 2010, GreenBlue .  All Rights Reserved.
 */

package jp.co.greenblue.ecodasweb.web.struts2.action;

import java.io.File;

import com.opensymphony.xwork2.ActionSupport;

/**
 * ClassName:UploadAction Function: TODO ADD FUNCTION Reason: TODO ADD REASON
 * 
 * @author jonsion
 * @version
 * @since Ver 1.1
 * @Date 2010/11/12 14:56:56
 * 
 * @see
 */
public class UploadAction extends ActionSupport {
	/**
	 * serialVersionUID:TODO（用一句话描述这个变量表示什么）
	 *
	 * @since Ver 1.1
	 */
	
	private static final long serialVersionUID = -1513523069499949257L;
	private File upload;
	private String fileName;
	private String uploadContentType;

	public String getUploadFileName() {
		return fileName;
	}

	public void setUploadFileName(String fileName) {
		this.fileName = fileName;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public void setUploadContentType(String contentType) {
		this.uploadContentType = contentType;
	}

	public String getUploadContentType() {
		return this.uploadContentType;
	}

	public String execute() throws Exception {
		java.io.InputStream is = new java.io.FileInputStream(upload);
		java.io.OutputStream os = new java.io.FileOutputStream("d:\\upload\\"
				+ fileName);
		byte buffer[] = new byte[8192];
		int count = 0;
		while ((count = is.read(buffer)) > 0) {
			os.write(buffer, 0, count);
		}
		os.close();
		is.close();
		return SUCCESS;
	}
}
